package com.coco.admin.controller;

import com.coco.admin.pojo.TbAdmin;
import com.coco.admin.service.SysUserLoginService;
import com.coco.admin.vo.LoginAdminVo;
import com.coco.common.result.CommonResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author minicoco
 * @version 1.0
 * @date 2021/7/23 11:21
 */
@RestController
@RequestMapping("/login")
public class SysUserLoginController {

    @Autowired
    private SysUserLoginService userLoginService;

    /**
     * 用户登录
     * @param adminVo
     * @return
     */
    @PostMapping("/doLogin")
    public CommonResponse adminLogin(@RequestBody LoginAdminVo adminVo){
        return userLoginService.adminLogin(adminVo);
    }


    /**
     * 查询登录用户信息
     * @param token
     * @return
     */
    @GetMapping("/findLoginUser")
    public TbAdmin  findLoginUser(@RequestHeader("token") String token){
        return userLoginService.findLoginUser(token);
    }

    /**
     * 退出登录
     * @param token
     * @param type
     * @return
     */
    @GetMapping("/logout")
    public CommonResponse logout(@RequestHeader("token") String token,@RequestHeader("type") String type){
        return userLoginService.logout(token,type);
    }

}
